package com.example.tests;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import java.util.Set;

import org.testng.annotations.Test;


public class GroupRemovalTests extends TestBase{
	@Test
	public void testfirstGroupCanBeRemoved() throws Exception {
		Set<GroupObject> oldList = app.getGroupHelper().getGroups();
		GroupObject group = app.getGroupHelper().selectFirstGroup();
		app.getGroupHelper().deleteGroup(0);		
		Set<GroupObject> newList = app.getGroupHelper().getGroups();
		verifyGroupDeleted(oldList, group, newList);
	}

	private void verifyGroupDeleted(Set<GroupObject> oldList, GroupObject group,
			Set<GroupObject> newList) {
		assertThat(newList.size(), equalTo(oldList.size() - 1));
		oldList.remove(group);
		assertThat(newList, equalTo(oldList));
	}
	
}